home *** CD-ROM | disk | FTP | other *** search
/ The Atari Compendium / The Atari Compendium (Toad Computers) (1994).iso / files / prgtools / programm.ing / falcon / nt_dsp2.lzh / NT_DSP2.MSA / BENCH / B-96 < prev    next >
Encoding:
Text File  |  1988-08-24  |  8.8 KB  |  219 lines

  1.     page 132,60,1,1
  2. ;*******************************************
  3. ;Motorola Austin DSP Operation  June 30,1988
  4. ;*******************************************
  5. ;DSP960002
  6. ;Memory to Memory FFT - 256 point
  7. ;File name: B-96.asm
  8. ;**************************************************************************
  9. ;    Maximum sample rate:  319.4 us at 27.0 MHz
  10. ;    Memory Size: Prog:  137 words ; Data:  1280 words
  11. ;    Number of clock cycles:     8624 (4312 instruction cycles)
  12. ;    Clock Frequency:    27.0MHz
  13. ;    Instruction cycle time:    74.1ns
  14. ;**************************************************************************
  15. ;
  16. ; Complex, Radix 2 Cooley-Tukey Decimation in Time FFT
  17. ; Untested
  18. ;
  19. ; Faster FFT using Programming Tricks found in Typical FORTRAN Libraries
  20. ;
  21. ;      First two passes combined as a four butterfly loop since
  22. ;            multiplies are trivial.
  23. ;            2.25 cycles internal (4 cycles external) per Radix 2 
  24. ;            butterfly.
  25. ;      Middle passes performed with traditional, triple-nested DO loop.
  26. ;            4 cycles internal (8 cycles external) per Radix 2 butterfly
  27. ;            plus overhead.  Note that a new pipelining technique is 
  28. ;            being used to minimize overhead.
  29. ;      Next to last pass performed with double butterfly loop.
  30. ;            4.5 cycles internal (8.5 cycles external) per Radix 2
  31. ;            butterfly.
  32. ;      Last pass has separate single butterfly loop.
  33. ;            5 cycles internal (9 cycles external) per Radix 2 
  34. ;            butterfly.
  35. ;
  36. ;      For 256 complex points, average Radix 2 butterfly = 3.8 cycles
  37. ;      internal and 7.35 cycles external, assuming a single external
  38. ;      data bus.
  39. ;
  40. ;      Because of separate passes, minimum of 32 points using these
  41. ;      optimizations.  Approximately 150 program words required. 
  42. ;      Uses internal X and Y Data ROMs for twiddle factor coefficients
  43. ;      for any size FFT up to 1024 complex points.
  44. ;                           
  45. ; First two passes
  46. ;
  47. ;      9 cycles internal, 1.77X faster than 4 cycle Radix 2 bfy
  48. ;      16 cycles external, 2.0X faster than 4 cycle Radix 2 bfy
  49. ;
  50. ;      r0 = a pointer in & out
  51. ;      r6 = a pointer in
  52. ;      r4 = b pointer in & out
  53. ;      r1 = c pointer in & out
  54. ;      r5 = d pointer in & out
  55. ;      n5 = 2
  56. ;
  57. ;      normally ordered input data
  58. ;      normally ordered output data
  59. ;
  60.       move      #points,d1.l
  61.       move      #passes,d9.l
  62.       move      #data,d0.l
  63.       move      #coef,m2
  64.       move      #coefsize,d2.l
  65.  
  66.       lsr      d1         d0.l,r0
  67.       lsr      d1         r0,r2
  68.       add      d1,d0      d1.l,d8.l
  69.       add      d1,d0      d0.l,r4
  70.       add      d1,d0      d0.l,r1
  71.       lsr      d2         d0.l,r5
  72.       lsr      d2         r0,r6
  73.       move      #2,n5
  74.       move      d2.l,n6
  75.       move      #-1,m0
  76.       move      m0,m1
  77.       move      m0,m4
  78.       move      m0,m5
  79.       move      m0,m6
  80.  
  81.       fmove                             x:(r0),d1.s
  82.       fmove                             x:(r1),d0.s             
  83.       fmove                             x:(r5)-,d2.s            
  84.       fmove                                          y:(r5)+,d4.s
  85.       faddsub  d1,d0                    x:(r4),d5.s               
  86.       faddsub  d5,d2                                 y:(r4),d7.s  
  87. ;
  88. ;      Combine first two passes with trivial multiplies.
  89. ;
  90.       do      d8.l,_twopass
  91.  
  92.       faddsubr d0,d2                                   y:(r5),d6.s  
  93.       faddsub  d7,d6                     d2.s,x:(r0)+  y:(r6)+,d3.s 
  94.       faddsubr d1,d7                     d0.s,x:(r4)   y:(r1)+,d2.s 
  95.       faddsub  d3,d2                     d1.s,x:(r5)-             
  96.       faddsubr d2,d6                     x:(r0)-,d1.s  d4.s,y:(r5)+n5
  97.       faddsubr d3,d5                     x:(r1)-,d0.s  d2.s,y:(r4)+  
  98.       faddsub  d1,d0                     x:(r5),d2.s   d6.s,y:(r0)+  
  99.       ftfr     d5,d4                     x:(r4),d5.s   d3.s,y:(r1)   
  100.       faddsub  d5,d2                     d7.s,x:(r1)+  y:(r4),d7.s    
  101. _twopass
  102.       fmove                                            d4.s,y:(r5)+   
  103. ;
  104. ; Middle passes
  105. ;
  106.       tfr      d9,d3      #4,d0.l
  107.       clr      d2         d8.l,d1.l
  108.       sub      d0,d3      d2.l,m6
  109.       do      d3.l,_end_pass
  110.       move    d0.l,n2
  111.       move    r2,r0
  112.       lsr     d1      m2,r6
  113.       dec     d1      d1.l,n0
  114.       dec     d1      d1.l,n1
  115.       move    d1.l,n3
  116.       move    n0,n4
  117.       move    n0,n5
  118.       lea     (r0)+n0,r1
  119.       move    r0,r4
  120.       move    r1,r5
  121.       fmove                             x:(r6)+n6,d9.s y:(),d8.s
  122.       fmove                                            y:(r1),d7.s
  123.       fmpy    d8,d7,d3                  x:(r1)+,d6.s
  124.       fmpy    d9,d6,d0
  125.       fmpy    d9,d7,d1                                 y:(r1),d7.s
  126.       fmpy    d8,d6,d2  fadd     d3,d0  x:(r0),d4.s
  127.       fmpy    d8,d7,d3  faddsubr d4,d0  x:(r1)+,d6.s
  128.  
  129.       do      n2,_end_grp
  130.  
  131.       do      n3,_end_bfy
  132.       fmpy    d9,d6,d0  fsub     d1,d2  d0.s,x:(r4)    y:(r0)+,d5.s
  133.       fmpy    d9,d7,d1  faddsubr d5,d2  d4.s,x:(r5)    y:(r1),d7.s
  134.       fmpy    d8,d6,d2  fadd     d3,d0  x:(r0),d4.s    d2.s,y:(r5)+
  135.       fmpy    d8,d7,d3  faddsubr d4,d0  x:(r1)+,d6.s   d5.s,y:(r4)+
  136. _end_bfy
  137.       move      (r1)+n1
  138.       fmpy    d9,d6,d0  fsub     d1,d2  d0.s,x:(r4)    y:(r0)+,d5.s
  139.       fmpy    d9,d7,d1  faddsubr d5,d2  d4.s,x:(r5)    y:(r1),d7.s
  140.       fmpy    d8,d6,d2  fadd     d3,d0  x:(r0),d4.s    d2.s,y:(r5)+
  141.       fmove                             x:(r6)+n6,d9.s y:(),d8.s
  142.       fmpy    d8,d7,d3  faddsubr d4,d0  x:(r1)+,d6.s   d5.s,y:(r4)+
  143.       fmpy    d9,d6,d0  fsub     d1,d2  d0.s,x:(r4)    y:(r0)+n0,d5.s
  144.       fmpy    d9,d7,d1  faddsubr d5,d2  d4.s,x:(r5)    y:(r1),d7.s
  145.       fmpy    d8,d6,d2  fadd     d3,d0  x:(r0),d4.s    d2.s,y:(r5)+n5
  146.       fmpy    d8,d7,d3  faddsubr d4,d0  x:(r1)+,d6.s   d5.s,y:(r4)+n4
  147. _end_grp
  148.       move     n2,d0.l
  149.       lsl      d0      n0,d1.l
  150. _end_pass
  151. ;
  152. ; next to last pass
  153. ;
  154.       move      d0.l,n2
  155.       move      r2,r0
  156.       move      r0,r4
  157.       lea      (r0)+2,r1
  158.       move      r1,r5
  159.       move      m2,r6
  160.       move      #3,n0
  161.       move      n0,n1
  162.       move      n0,n4
  163.       move      n0,n5
  164.       fmove                             x:(r6)+n6,d9.s  y:(),d8.s
  165.       fmove                                             y:(r1),d7.s
  166.       fmpy    d8,d7,d3                  x:(r1)+,d6.s
  167.       fmpy    d9,d6,d0
  168.       fmpy    d9,d7,d1                                  y:(r1),d7.s
  169.       fmpy    d8,d6,d2  fadd     d3,d0  x:(r0),d4.s
  170.       fmpy    d8,d7,d3  faddsubr d4,d0  x:(r1)+n1,d6.s
  171.  
  172.       do      n2,_end_next
  173.       fmpy    d9,d6,d0  fsub     d1,d2  d0.s,x:(r4)     y:(r0)+,d5.s
  174.       fmpy    d9,d7,d1  faddsubr d5,d2  d4.s,x:(r5)     y:(r1),d7.s
  175.       fmpy    d8,d6,d2  fadd     d3,d0  x:(r0),d4.s     d2.s,y:(r5)+
  176.       fmove                             x:(r6)+n6,d9.s  y:(),d8.s
  177.       fmpy    d8,d7,d3  faddsubr d4,d0  x:(r1)+,d6.s    d5.s,y:(r4)+
  178.       fmpy    d9,d6,d0  fsub     d1,d2  d0.s,x:(r4)     y:(r0)+n0,d5.s
  179.       fmpy    d9,d7,d1  faddsubr d5,d2  d4.s,x:(r5)     y:(r1),d7.s
  180.       fmpy    d8,d6,d2  fadd     d3,d0  x:(r0),d4.s     d2.s,y:(r5)+n5
  181.       fmpy    d8,d7,d3  faddsubr d4,d0  x:(r1)+n1,d6.s  d5.s,y:(r4)+n4
  182. _end_next
  183. ;
  184. ; last pass
  185. ;
  186.       move      n2,d0.l        ;# previous groups ->d0
  187.       lsl       d0      r2,r0    ;update # groups, r0 points to input data A
  188.       move      d0.l,n2        ;# stages ->n2
  189.       move      #odata,r4    ;r4 points to A output
  190.       lea      (r0)+,r1         ;r1 points to B input
  191.       move      r4,r2        ;r2 points to A output                 
  192.       move      m2,r6           ;r6 points to twiddle factors  
  193.       move      #2,n0        ;offset is 2 for A input pointer
  194.       move      n0,n1        ;offset is 2 for B input pointer
  195.       lea    (r2)+n2,r5    ;r5 points to B output
  196.       move     #points/4,n4    ;offset is #points/4 for A output pointer
  197.       move      n4,n5        ;offset is #points/4 for B output pointer
  198.       move     #0,m4        ;bit reversed addressing for A output pointer
  199.       move     m4,m5        ;bit reversed addressing for B output pointer
  200.  
  201.       fmove                             x:(r6)+n6,d9.s  y:(),d8.s
  202.       fmove                                             y:(r1),d7.s
  203.       fmpy    d8,d7,d3                  x:(r1)+n1,d6.s
  204.       fmpy    d9,d6,d0
  205.       fmpy    d9,d7,d1                                  y:(r1),d7.s
  206.       fmpy    d8,d6,d2  fadd     d3,d0  x:(r0),d4.s
  207.       fmove                             x:(r6)+n6,d9.s  y:(),d8.s
  208.       fmpy    d8,d7,d3  faddsubr d4,d0  x:(r1)+n1,d6.s
  209.  
  210.       do      n2,_end_last
  211.       fmpy    d9,d6,d0  fsub     d1,d2  d0.s,x:(r4)     y:(r0)+n0,d5.s
  212.       fmpy    d9,d7,d1  faddsubr d5,d2  d4.s,x:(r5)     y:(r1),d7.s
  213.       fmpy    d8,d6,d2  fadd     d3,d0  x:(r0),d4.s     d2.s,y:(r5)+n5
  214.       fmove                             x:(r6)+n6,d9.s  y:(),d8.s
  215.       fmpy    d8,d7,d3  faddsubr d4,d0  x:(r1)+n1,d6.s  d5.s,y:(r4)+n4
  216. _end_last
  217.  
  218.  
  219.